package com.lvwenguo.test;

/*
* 测试线程
* */
public class MyTestXianceng {
    public static void main(String[] args) {
        MyThread myThread=new MyThread();

        MyRunnable myRunnable=new MyRunnable();
        Thread thread=new Thread(myRunnable);

        Mytest mytest=new Mytest();

            for(int i=0;i<5;i++){
                System.out.println("我是main1执行的数值"+i);
            }

            myThread.start();
            //thread.start();
            //mytest.run();

        for(int i=0;i<5;i++){
            System.out.println("我是main2执行的数值"+i);
        }
    }
}

class MyRunnable implements Runnable{

    @Override
    public void run() {
       /* try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        for(int i=0;i<10;i++){
            System.out.println("我是MyRunnable中运行的"+i);
        }
    }
}
class Mytest{
    public void run(){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        for(int i=0;i<10;i++){
            System.out.println("我是Mytest中运行的"+i);
        }
    }

}
class MyThread extends Thread{
    @Override
    public void run() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        for(int i=0;i<10;i++){
            System.out.println("我是MyThread中运行的"+i);
        }

    }
}